package com.wzz.first.ptpConsumer;

import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.*;

public class One {
    public static void main(String[] args) throws JMSException {
        ConnectionFactory factory = new ActiveMQConnectionFactory("tcp://192.168.1.47:61616");
        Connection connection = factory.createConnection();
        connection.start();;
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Queue queue = session.createQueue("queue01");
        MessageConsumer consumer = session.createConsumer(queue);

        //接收消息
        while(true){
            Message receive = consumer.receive();
            if (receive == null){
                break;
            }

            if(receive instanceof TextMessage){
                System.out.println(((TextMessage) receive).getText());
            }
        }


    }
}
